package com.jiangyg.mall.product.service;

import com.jiangyg.mall.db.mybatis.BaseServiceImpl;
import com.jiangyg.mall.core.support.restful.Pagination;
import com.jiangyg.mall.product.dto.CommentReplayDTO;
import com.jiangyg.mall.product.entity.CommentReplay;
import com.jiangyg.mall.product.vo.CommentReplayVO;
import com.jiangyg.mall.product.dao.CommentReplayDao;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CommentReplayServiceImpl extends BaseServiceImpl<CommentReplayDao, CommentReplay> implements CommentReplayService {

    @Autowired
    public CommentReplayServiceImpl(CommentReplayDao commentReplayDao) {
        super(commentReplayDao);
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public Pagination<CommentReplayVO> selectPagination(Pagination<CommentReplayVO> pagination) throws Exception {
        return this.executeSelectPagination(pagination, CommentReplayVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean saveOrUpdate(CommentReplayDTO dto) throws Exception {
        return this.executeSaveOrUpdate(dto) > 0;
    }

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
    public CommentReplayVO selectById(Long commentReplayId) throws Exception {
        return this.executeSelectById(commentReplayId, CommentReplayVO.class);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean delete(List<Long> commentReplayIds) {
        return this.baseMapper.deleteBatchIds(commentReplayIds) > 0;
    }

}
